// packagePay/pages/insurance-success/insurance-success.js
import { insuranceReportDetail, revokeReportCase} from '../../api/insurance'
import {confirm,toast} from '../../../utils/util'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        detailInfo:{}
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        console.log(options,'options')
        this.getInsuranceReportDetail(options.id)
    },
    getInsuranceReportDetail(id){
        insuranceReportDetail({id:id}).then(res=>{
            console.log(res,'res')
            // res.params.fileUrl.forEach((item,index)=>{
            //     res.params.fileUrl[index].fileUrl = JSON.parse(item.fileUrl)
            // })
            this.setData({
                detailInfo:res,
            })
        })
    },
    // 撤销报案
    async onRevokeReportCase(event){
        console.log(event,'event')
        confirm('确认撤销当前报案吗').then(()=>{
            revokeReportCase({id:this.data.detailInfo.id}).then(()=>{
                this.getInsuranceReportDetail(this.data.detailInfo.id)
                toast('撤销成功')
            })
        })
        
    },
    onPreview(event) {
        const { url } = event.currentTarget.dataset
        wx.previewImage({
            urls: [url]
        })
    },
    onPlay(event) {
        console.log(event.currentTarget.id)
        console.log(this, 'this')
        // 获取 video 上下文 videoContext 对象
        this.videoContext = wx.createVideoContext(event.currentTarget.id, this)
        // 进入全屏状态
        this.videoContext.requestFullScreen()
        return 0
    },
})